# 打印出杨辉三角
def print_pascal_triangle(n):
    triangle = [[0 for _ in range(n)] for _ in range(n)]

    # 初始化第一列和对角线元素为1
    for i in range(n):
        triangle[i][0] = 1
        triangle[i][i] = 1

    # 根据杨辉三角的定义填充其他元素
    for i in range(2, n):
        for j in range(1, i):
            triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j]

    # 打印杨辉三角
    for i in range(n):
        for j in range(i + 1):
            print(triangle[i][j], end=" ")
        print()

    # for row in triangle:
    #     print(" ".join(str(num) for num in row))


if __name__ == "__main__":
    print_pascal_triangle(10)
